package com.mz.ozy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.mz.ozy.R;
import com.mz.ozy.bean.BalanceDetailBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 *
 */

public class BalanceDetailAdapter extends RecyclerView.Adapter<BalanceDetailAdapter.MyViewHolder> {


    private Context mContext;
    List<BalanceDetailBean.PageBean.PageItemsBean> mBeanList;

    public BalanceDetailAdapter(Context context, List<BalanceDetailBean.PageBean.PageItemsBean> mBeanList) {
        mContext = context;
        this.mBeanList = mBeanList;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_balance_detail, parent, false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {

         /* page(uid-用户名 amount-金额 remark-备注 sztype(0-收入 1-支出)
        lxtype(0-充币1提币2手动调整3静态收益4分享收益5团队收益6投资7转账8提币失败9锁仓10-锁仓返回 11-兑换 12-抽奖
        13-锁仓返单 14-节点游戏收益 15-直推动态收益 16-锁仓收益))*/

        BalanceDetailBean.PageBean.PageItemsBean bean = mBeanList.get(position);
        int sztype = bean.getStype();
        if (sztype == 0) {
            holder.tvMoney.setTextColor(mContext.getResources().getColor(R.color.c_f63148));
            holder.tvMoney.setText("+" + bean.getAmt());
        } else if (sztype == 1) {
            holder.tvMoney.setTextColor(mContext.getResources().getColor(R.color.text_color_333333));
            holder.tvMoney.setText("-" + bean.getAmt());
        }
        holder.tvUnit.setText(bean.getCoin());
        holder.tvDate.setText(bean.getCreated());
        int lxtype = bean.getType();
        switch (lxtype) {
            case 0:
                holder.tvRemark.setText(R.string.cb_status_add);
                break;
            case 1:
                holder.tvRemark.setText(R.string.tb_status_label);
                break;
            case 2:
                holder.tvRemark.setText(R.string.usdt_detail_type1);
                break;
            case 3:
                holder.tvRemark.setText(R.string.static_income);
                break;
            case 4:
                holder.tvRemark.setText(R.string.sharing_revenue);
                break;
            case 5:
                holder.tvRemark.setText(mContext.getString(R.string.group_income));
                break;
            case 6:
                holder.tvRemark.setText(mContext.getString(R.string.investment));
                break;
            case 7:
                holder.tvRemark.setText(mContext.getString(R.string.transfer));
                break;
            case 8:
                holder.tvRemark.setText(R.string.withdraw_coins_failed);
                break;
            case 9:
                holder.tvRemark.setText(R.string.lock_ware);
                break;
            case 10:
                holder.tvRemark.setText(mContext.getString(R.string.lock_ware_back));
                break;
            case 11:
                holder.tvRemark.setText(R.string.exchange);
                break;
            case 12:
                holder.tvRemark.setText(mContext.getString(R.string.lottery));
                break;
            case 13:
                holder.tvRemark.setText(mContext.getString(R.string.lockware_return));
                break;
            case 14:
                holder.tvRemark.setText(mContext.getString(R.string.node_game_revenue));
                break;
            case 15:
                holder.tvRemark.setText(mContext.getString(R.string.direct_dynamic_gain));
                break;
            case 16:
                holder.tvRemark.setText(mContext.getString(R.string.lockout_income));
                break;
            case 17:
                holder.tvRemark.setText(mContext.getString(R.string.redeem_game));
                break;
            case 18:
                holder.tvRemark.setText(mContext.getString(R.string.thaw));
                break;
            case 19:
                holder.tvRemark.setText(mContext.getString(R.string.pledge_str));
                break;
            case 20:
                holder.tvRemark.setText(mContext.getString(R.string.pledged_release));
                break;
            case 21:
                holder.tvRemark.setText(mContext.getString(R.string.partner_rebate));
                break;
        }


    }

    @Override
    public int getItemCount() {
        return mBeanList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_remark)
        TextView tvRemark;
        @BindView(R.id.tv_date)
        TextView tvDate;
        @BindView(R.id.tv_money)
        TextView tvMoney;
        @BindView(R.id.tv_unit)
        TextView tvUnit;
        @BindView(R.id.ll_item)
        LinearLayout llItem;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }


    }


}
